﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application
{
    /// <summary>
    /// 应用层统一返回模型
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public record OperationResult<T>
    {
        public T? Data { get; init; }

        public ICollection<ErrorResult> Errors { get; init; } = [];

        public bool IsSuccess => Errors.Count == 0;
    }

    /// <summary>
    /// 应用层错误模型
    /// </summary>
    public record ErrorResult
    {
        public string Message { get; init; } = null!;

        public object? Id { get; init; }

        public string ErrorCode { get; init; } = null!;
    }
}
